package com.furnitur.modules.portal.controller;

import com.furnitur.common.api.Result;
import com.furnitur.modules.portal.service.PortalCategoryService;
import com.furnitur.modules.portal.vo.category.CategoryVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/api/portal/categories")
public class PortalCategoryController {

    @Autowired
    private PortalCategoryService categoryService;

    @GetMapping("/list")
    public Result<List<CategoryVO>> list() {
        log.info("Getting all categories");
        List<CategoryVO> categories = categoryService.listAllCategories();
        return Result.success(categories);
    }

    @GetMapping("/{id}")
    public Result<CategoryVO> getById(@PathVariable Long id) {
        log.info("Getting category by id: {}", id);
        CategoryVO category = categoryService.getCategoryById(id);
        return Result.success(category);
    }
} 